#ifndef FORTRESS_INPUT_H
#define FORTRESS_INPUT_H
#include <map>
#include "libtcod.hpp"
#include "eventHandler.h"
#include "boost/crc.hpp"

namespace fortress
{
	class messageController;
	class character;

	class inputController
	{
	
	private:
		std::map<int, int> mappedInput;	// Maps input to hashed commands
		eventReceiver * controlledCharacter;	// A pointer to send character inputs to
		bool running;	// Should the program continue?
		bool save;		// If the program is no longer running, run save game routines?
		TCOD_key_t savedKey;	// Saves the last key pressed if the action takes multiple inputs
		messageController & messages;
		// Take a keypress received from the user and send a command
		bool translateInput(TCOD_key_t keypress);
		// The user requests the program to exit
		void stop(bool savegame);
		// Takes hashed input and returns a direction
		moveDirections readDirection(int input); 

		void getDirection(TCOD_key_t keypress);

	public:
		inputController();
		~inputController();

		// Set the input focus on a new character
		void setControlled(eventReceiver * setCharacter);
		// Reads input mapping from a file
		void getMapping(char const *filename);	
		// Returns true unless a quit command was issued
		bool isRunning();
		bool doSave();
		// Get player input, and then send it to the character the player controls
		bool waitForInput();
		void waitForKeypress();
	
	};
};
#endif